#!/bin/sh

G_CHIP_TYPE="$1"
G_PRO_NAME="$2"

../com_audio_img_mk.sh $G_CHIP_TYPE $G_PRO_NAME
../com_app_img_mk.sh $G_CHIP_TYPE $G_PRO_NAME

SRC_DIR="../filesys"
DST_FILE="sys.img"
DST_DIR="/tftp/"
HTTP_DIR="/var/www/html/"

rm ../filesys/* -rf
git checkout ../filesys
cp filesys/* ../filesys/ -rf
chmod 777 ../filesys/ -R

echo ">>>>>> ###### rm $DST_FILE"
rm $DST_FILE

../com_mksquashfs.sh $G_CHIP_TYPE $SRC_DIR $DST_FILE

echo ">>>>>> ###### rm $DST_DIR$DST_FILE"
rm $DST_DIR$DST_FILE

echo ">>>>>> ###### rm $HTTP_DIR$DST_FILE"
rm $HTTP_DIR$DST_FILE

echo ">>>>>> ###### cp $DST_FILE $DST_DIR"
cp $DST_FILE $DST_DIR

echo ">>>>>> ###### cp $DST_FILE $HTTP_DIR"
cp $DST_FILE $HTTP_DIR

rm sys_info*
g_sys_ver=`cat filesys/usr/ipcam/bak/soc_version.txt`
g_now_time=`date +%Y-%m-%d_%H-%M-%S`
touch sys_info_$g_sys_ver'_'$g_now_time

